<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>个人资料</title>
		<link href="css/user-details.css" rel="stylesheet">
		<link href="css/imgs.css" rel="stylesheet">
		<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
	</head>

	<body>
		<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-/mhDoLbDldZc3qpsJHpLogda//BVZbgYuw6kof4u2FrCedxOtgRZDTHgHUhOCVim" crossorigin="anonymous"></script>

		<!-- <div class="top-blank">
			<a href="selectAllServlet" class="home-page">首页</a>
			<p><img src="imgs/shopping-cart.webp" class="shopping-cart-img">购物车</p>
		</div> -->

		<nav class="navbar navbar-expand-lg bg-body-tertiary">
      <div class="container-fluid">
        <a class="navbar-brand" href="/request-demo/selectAllServlet">电商平台</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav">
            <li class="nav-item">
              <a class="nav-link active" aria-current="page" href="/request-demo/selectAllServlet">首页</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/request-demo/viewProfileServlet">${user.username}</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/request-demo/shoppingCartSelectServlet"><img src="imgs/shopping-cart.webp" class="shopping-cart-img">购物车</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/request-demo/myStoreServlet"><img src="imgs/shop-logo.webp" class="shop-logo">我的店铺</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>

		<main>
			<ul class="list-group">
				<li class="list-group-item active" aria-current="true">个人资料</li>
				<li class="list-group-item">用户名：${user.username}</li>
				<li class="list-group-item">邮箱：${user.email}</li>
			</ul>
			
			<div class="d-grid gap-2 d-md-block">
				<a class="btn btn-danger" href="/request-demo/logoutServlet" role="button" id="logout">退出登录</a>
				<a class="btn btn-danger" href="/request-demo/cancelAccountServlet" role="button" id="cancel-account">注销账户</a>
			</div>
		</main>

		<!-- <div>
			<p>用户名：${user.username}</p>
			<p>邮箱：${user.email}</p>
			<form action="/request-demo/logoutServlet" onsubmit="return logout_check()" method="post">
				<button type="submit" id="logout">退出登录</button>
			</form>
			<form action="/request-demo/cancelAccountServlet" onsubmit="return cancel_check()" method="post">
				<button type="submit" id="cancel-account">注销账户</button>
			</form>
		</div> -->

		<script>
			let logout = document.getElementById("logout");
			logout.onclick = function logout_check() {
				if (window.confirm('您确定要退出登录吗？')) {
					return true;
				} else {
					return false;
				}
			}

			let cancel_account = document.getElementById("cancel-account");
			cancel_account.onclick = function cancel_check() {
				if (window.confirm('您确定要注销账户吗？此过程不可恢复！')) {
					return true;
				} else {
					return false;
				}
			}
		</script>
	</body>
</html>